<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var arr02=[2,8,5,7,4,10];
        //选择排序
        for(i=0;i<arr02.length-1;i++){
            minPos=i+1;
            for(j=i+1;j<arr02.length;j++){
                if(arr02[j]<arr02[minPos]) minPos=j;
                
            }
            //交换
            if(arr02[i]>arr02[minPos]){
                temp=arr02[i];
                arr02[i]=arr02[minPos];
                arr02[minPos]=temp;
            }
        }
        console.log(arr02);
    </script>
</body>
</html>